package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        /*连接数据库-----------------------------------------------------------*/
        Class.forName("com.mysql.cj.jdbc.Driver");
        System.out.println("开始连接数据库");
        long start = System.currentTimeMillis();
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:8164/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "123457");
        Statement stmt = conn.createStatement();
        System.out.println("连接成功,耗时" + (System.currentTimeMillis() - start) + "ms");
        /*连接数据库-----------------------------------------------------------*/
        String sql = "UPDATE user " +
                "SET password='666666',age=18,nickname='张三疯'"+
                "WHERE username = '张三'";
        stmt.executeUpdate(sql);

    }
}
